package com.gxa.controller;

import com.gxa.pojo.*;
import com.gxa.utils.Constants;
import com.gxa.utils.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: zxy
 * Date: 2020/11/26 9:59
 * Description:
 * Version: V1.0
 */
@RestController
@RequestMapping("/orderList")
@Api(value = "订单列表",tags = "订单列表")
public class orderListController {

    @Autowired
    private ResponseData responseData;

    @GetMapping(value = "/queryOrderList")
    @ApiOperation(value = "查询订单列表",notes = "查询订单列表",httpMethod = "GET", response = ResponseData.class)
    public ResponseData queryOrderList(){
        Order order = new Order();
        order.setOrderId(1);
        order.setOrderCode("订单编号");
        order.setOrderOt(new Date());
        MemLocations memLocations = new MemLocations();
        memLocations.setMemName("收货人");
        memLocations.setMemLocation("收获地址");
        memLocations.setMemNum("电话");
        order.setMemLocations(memLocations);
        Goods goods = new Goods();
        goods.setGoodsName("商品名称");
        goods.setGoodsPrice(1000.00);
        goods.setGoodsPp("商品图片");
        order.setGoods(goods);
        Costinfor costinfor = new Costinfor();
        costinfor.setCostinforPq(2);
        costinfor.setCostinforTaog(2000.00);
        order.setCostinfor(costinfor);
        Ordoper ordoper = new Ordoper();
        ordoper.setOrdoperStatu(1);
        order.setOrdoper(ordoper);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(order);
        return responseData;
    }

    @GetMapping(value = "/queryOrderListByNameAndCode")
    @ApiOperation(value = "按照订单号收货人查询订单列表",notes = "按照订单号收货人查询订单列表",httpMethod = "GET", response = ResponseData.class)
    public ResponseData queryOrderListByNameAndCode(String orderCode, String memName){
        Order order = new Order();
        order.setOrderId(1);
        order.setOrderCode("订单编号"+orderCode);
        order.setOrderOt(new Date());
        MemLocations memLocations = new MemLocations();
        memLocations.setMemName("收货人"+memName);
        memLocations.setMemLocation("收获地址");
        memLocations.setMemNum("电话");
        order.setMemLocations(memLocations);
        Goods goods = new Goods();
        goods.setGoodsName("商品名称");
        goods.setGoodsPrice(1000.00);
        goods.setGoodsPp("商品图片");
        order.setGoods(goods);
        Costinfor costinfor = new Costinfor();
        costinfor.setCostinforPq(2);
        costinfor.setCostinforTaog(2000.00);
        order.setCostinfor(costinfor);
        Ordoper ordoper = new Ordoper();
        ordoper.setOrdoperStatu(1);
        order.setOrdoper(ordoper);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(order);
        return responseData;
    }

    @GetMapping(value = "/queryOrderDetails")
    @ApiOperation(value = "查询订单详情",notes = "查询订单详情",httpMethod = "GET", response = ResponseData.class)
    public ResponseData queryOrderDetails(){
        Order order = new Order();
        order.setOrderCode("订单编号");
        order.setOrderBu("购买用户");
        order.setOrderOt(new Date());
        order.setOrderPm("支付方式");
        order.setOrderPt(new Date());
        order.setOrderDm("配送方式");
        order.setOrderDt(new Date());
        order.setOrderIn("发货单号");
        order.setOrderCm("客户留言");
        MemLocations memLocations = new MemLocations();
        memLocations.setMemName("姓名");
        memLocations.setMemNum("手机");
        memLocations.setMemLocation("收货地址");
        order.setMemLocations(memLocations);
        Comspec comspec = new Comspec();
        comspec.setComspecName("规格");
        comspec.setNumber("货号");
        Goods goods = new Goods();
        goods.setGoodsName("商品名称");
        goods.setGoodsPrice(1000.00);
        goods.setGoodsCi(5000);
        goods.setGoodsCw(4);
        goods.setComspec(comspec);
        order.setGoods(goods);
        Costinfor costinfor = new Costinfor();
        costinfor.setCostinforPq(2);
        costinfor.setCostinforTaog(2000.00);
        costinfor.setCostinforDc(0.00);
        costinfor.setCostinforAp(0.00);
        costinfor.setCostinforUca(0.00);
        costinfor.setCostinforAd(2000.00);
        order.setCostinfor(costinfor);
        Ordoper ordoper = new Ordoper();
        ordoper.setModeDis("配送方式");
        ordoper.setOpera("操作者");
        ordoper.setOrdoperTime(new Date());
        ordoper.setOrdoperStatu(1);
        ordoper.setPayStatu(1);
        ordoper.setDelivStatu(1);
        ordoper.setOrdoperDesc("操作备注");
        order.setOrdoper(ordoper);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("查询成功");
        responseData.setData(order);
        return responseData;
    }

    @GetMapping(value = "/updatePayStatu")
    @ApiOperation(value = "更改支付状态",notes = "更改支付状态",httpMethod = "GET", response = ResponseData.class)
    public ResponseData updatePayStatu(){
        Order order = new Order();
        Ordoper ordoper = new Ordoper();
        ordoper.setPayStatu(1);
        order.setOrdoper(ordoper);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("更改成功");
        responseData.setData(null);
        return responseData;
    }

    @GetMapping(value = "/updateDelivStatu")
    @ApiOperation(value = "更改发货状态",notes = "更改发货状态",httpMethod = "GET", response = ResponseData.class)
    public ResponseData updateDelivStatu(){
        Order order = new Order();
        Ordoper ordoper = new Ordoper();
        ordoper.setDelivStatu(1);
        order.setOrdoper(ordoper);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("更改成功");
        responseData.setData(null);
        return responseData;
    }

    @GetMapping(value = "/updateDelivStatus")
    @ApiOperation(value = "更改发货状态(一键发货)",notes = "更改发货状态(一键发货)",httpMethod = "GET", response = ResponseData.class)
    public ResponseData updateDelivStatus(){
        Order order = new Order();
        Ordoper ordoper = new Ordoper();
        ordoper.setDelivStatu(1);
        order.setOrdoper(ordoper);
        responseData.setCode(Constants.SUCCESS);
        responseData.setMsg("更改成功");
        responseData.setData(null);
        return responseData;
    }




}
